USE [GESTION_MORA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_D0007_CARGO_MORAEMP_MORA_SUC_7]    Script Date: 11/23/2011 15:17:43 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_D0007_CARGO_MORAEMP_MORA_SUC_7]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_D0007_CARGO_MORAEMP_MORA_SUC_7]
GO

USE [GESTION_MORA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_D0007_CARGO_MORAEMP_MORA_SUC_7]    Script Date: 11/23/2011 15:17:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[WASP_D0007_CARGO_MORAEMP_MORA_SUC_7]
AS

-- Detalle Desafiliados

TRUNCATE TABLE DBO.GMDETADESAFIL

INSERT INTO DBO.GMDETADESAFIL
SELECT     
	GMComercialDesafil.Cuenta_Empresa
	,GMComercialDesafil.Nombre_Empresa
	,GMComercialDesafil.Cuenta
	,GMComercialDesafil.Operacion
	,GMComercialDesafil.Nombre_Deudor
	,Vcto_Impago = GESTION_MORA.dbo.GMMora.Z073B3Fpag 
	,Valor_Cuota = CONVERT(NUMERIC, GESTION_MORA.dbo.GMMora.Z073B3CNo) 
FROM         
GMMora Left Join GMComercialDesafil ON
  GESTION_MORA.dbo.GMMora.Z073B3Cta  = GMComercialDesafil.Cuenta AND 
	GESTION_MORA.dbo.GMMora.Z073B3Oper = GMComercialDesafil.Operacion
/*
	GMMora 
	,GMComercialDesafil 
WHERE
	GESTION_MORA.dbo.GMMora.Z073B3Cta *= GMComercialDesafil.Cuenta AND 
	GESTION_MORA.dbo.GMMora.Z073B3Oper *= GMComercialDesafil.Operacion
*/	
GO

